package com.api.mapper;

import com.api.pojo.HealthScore;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface HealthScoreMapper {

    @Insert("insert into health_score(hid, cid) value(#{hid}, #{cid})")
    void create(Integer hid, Integer cid);

    @Update("update health_score set grade = #{grade} where id = #{id}")
    void update(HealthScore hs);

    @Select("select * from health_score where hid = #{hid} and grade is null limit #{pageNo}, #{pageSize}")
    List<HealthScore> get(Integer hid, Integer pageNo, Integer pageSize);

    @Select("select count(*) from health_score where hid = #{hid} and grade is null")
    Integer count(Integer hid);

    @Select("select * from health_score where hid = #{hid} and grade is not null limit #{pageNo}, #{pageSize}")
    List<HealthScore> getNotNull(Integer hid, Integer pageNo, Integer pageSize);

    @Select("select count(*) from health_score where hid = #{hid} and grade is not null")
    Integer countNotNull(Integer hid);

    @Delete("delete from health_score where hid = #{hid}")
    void remove(Integer hid);
}
